package com.hdaccp.xingmu.service.impl;

import com.hdaccp.xingmu.dao.Poi;

import com.hdaccp.xingmu.entity.House;
import com.hdaccp.xingmu.poi.WriteExcel;
import com.hdaccp.xingmu.service.PoiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@Service("poiService")
public class PoiServiceImpl implements PoiService {
    @Autowired
    private Poi poi;
    @Override
    public InputStream getInputStream() throws Exception {
        String[] title=new String[]{"门牌号","所属楼栋","所属单元","所属楼层","房屋户型","房屋朝向","房屋面积","当前状态","备注"};
        List<House> plist=poi.findAll();
        List<Object[]>  dataList = new ArrayList<Object[]>();
        for(int i=0;i<plist.size();i++){
            Object[] obj=new Object[9];
            obj[0]=plist.get(i).getDoornumber();
            obj[1]=plist.get(i).getSale().getName();
            obj[2]=plist.get(i).getDanyuan().getName();
            obj[3]=plist.get(i).getFloor();
            obj[4]=plist.get(i).getHuxing().getName();
            obj[5]=plist.get(i).getDirection().getName();
            obj[6]=plist.get(i).getMeasure();
            obj[7]=plist.get(i).getTypeb().getName();
            obj[8]=plist.get(i).getRemark();
            dataList.add(obj);
        }
        WriteExcel ex = new WriteExcel(title, dataList);
        InputStream in;
        in = ex.export();
        return in;
    }
}
